<?php 

class brand  {



	public function add($parm){
		DB::insert("sysbrand",array('name','sort','model'))->values(array($parm['name'],$parm['sort'],$parm['model']))->execute();
	}

	
	public function listdata($parm){
		$query = DB::query(Database::SELECT,
	         'select * from sysbrand   limit '.($parm['page']-1)*$parm['rows'].','.$parm['rows'])->execute()->as_array();
		$count = DB::query(Database::SELECT,
	         'select count(1) from sysbrand   ')->execute()->as_array();
		$data['total']=$count[0]['count(1)'];
		$data['rows']=$query;
		return $data;
	}
	public function getListBrand(){
		$result = DB::select('*')->from('sysbrand')->execute()->as_array();
		return $result;
	}
	public function detail($parm){
		$result = DB::select('*')->from('sysbrand')->where("id","=",$parm['id'])->execute()->as_array();
		return $result;
	}
	public function update($parm){
		DB::update("sysbrand")->set(array('name' => $parm['name'],'sort' => $parm['sort'],'model' => $parm['model']))
            ->where('id', '=', $parm['id'])->execute();

	}
	public function brandlist($parm){
		$result = DB::select('*')->from('sysbrand')->where("model","=",$parm["model"])->execute()->as_array();
		return $result;
	}
}